import tui from '@/common/tui'
const userInfo ={
	getUserInfo(callback){
		if(tt.getStorageSync("userInfo")){
			return
		}
		let  annoInfo = tt.getStorageSync('annoInfo')
		tt.getUserInfo({
			withCredentials: true,
			success(res1) {
				let u = res1.userInfo
				tt.setStorage({
				  key: "userInfo",
				  data: u
				});
				tt.setStorage({
				  key: "douyinId",
				  data: annoInfo.data.data.openid
				});
				let params = {
					"douyinId": annoInfo.data.data.openid,
					"nickName": u.nickName,
					"avatarUrl": u.avatarUrl,
					"sex": u.gender,
					"toutiaoId": annoInfo.data.data.unionid
				} 
				tui.tPostAction('/profile/proXxbProfileApi/add', params)
					.then((res) => {
						callback && callback()
						console.log(`getUserInfo 调365用成功 ${JSON.stringify(res)}`);
					})
			},
			fail(res) {
				console.log(`getUserInfo 调用失败`);
			},
		});
	}
}

export default userInfo
